import request from '@/utils/request'
import type { Result, PageParams, PageResult } from '@/types/api'

// 支付记录信息
export interface Payment {
  paymentId: number
  code: string
  orderType: string
  amount: number
  userId: number
  userName: string
  status: number
  createdAt: string
}

// 退款参数
export interface RefundParams {
  orderId: number
  orderType: string
  amount: number
  remarks?: string
}

// 分页查询支付记录
export function getPaymentList(params: PageParams & {
  orderType?: string
  userId?: number
  status?: number
}) {
  return request.get<Result<PageResult<Payment>>>('/admin/payments', { params })
}

// 退还押金
export function refund(data: RefundParams) {
  return request.post<Result<{ refundId: number; code: string; status: number }>>('/admin/payments/refund', data)
} 